package cn.duxiaod.demo.producerconsumer.b;

import java.util.Random;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;

public class ProducerBQ extends Thread{
    private LinkedBlockingQueue<Integer> blockingQueue;
    private String name;
    private Integer i = 0;
    public ProducerBQ(String name,LinkedBlockingQueue<Integer> blockingQueue){
        super(name);
        this.name = name;
        this.blockingQueue = blockingQueue;
    }
    @Override
    public void run() {
        while (true){
            try {
                blockingQueue.put(i);
                System.out.println("["+name+"]生产：+"+i);
                i++;
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
